package com.xsmart.goods.api;

import com.xsmart.common.entity.RequestBean;
import com.xsmart.common.entity.ResponseBean;
import com.xsmart.goods.services.GoodsCategoryService;
import com.xsmart.goods.services.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/api")
public class GoodsCategoryController {
    @Autowired
    GoodsCategoryService goodsCategoryService;

    @RequestMapping(value = "/v1/GoodsCategoryService/queryGoodsCategory", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean queryGoodsCategory(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return goodsCategoryService.queryGoodsCategory(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsCategoryService/addGoodsCategory", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean addGoodsCategory(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return goodsCategoryService.addGoodsCategory(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsCategoryService/modGoodsCategory", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean modGoodsCategory(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return goodsCategoryService.modGoodsCategory(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsCategoryService/delGoodsCategory", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean delGoodsCategory(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return goodsCategoryService.delGoodsCategory(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsCategoryService/findParentNode", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean findParentNode(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return goodsCategoryService.findParentNode(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsCategoryService/findParentId", method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean findParentId(@ModelAttribute RequestBean requestBean, HttpServletRequest request) {
        return goodsCategoryService.findParentId(requestBean);
    }
}
